package GUI;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import GUI.TabPanels.AddFeesPanel;
import GUI.TabPanels.AdminPanel;
import GUI.TabPanels.BookingPanel;
import GUI.TabPanels.CheckInPanel;
import GUI.TabPanels.CheckOutPanel;
import GUI.TabPanels.ViewGuestsPanel;

@SuppressWarnings("serial")
public class MainScreen extends JPanel{
	private JTabbedPane tabs;
	
	private BookingPanel booking_panel;
	private CheckInPanel check_in_panel;
	private CheckOutPanel check_out_panel;
	private ViewGuestsPanel view_guests_panel;
	private AddFeesPanel add_fees_panel;
	private AdminPanel admin_panel;
	
	public MainScreen(){
		 //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		 //setTitle("Suite Dreams Employee Version");
		 setSize(900,600);
		 //setResizable(false);
		 //this.setBackground(Color.PINK);


		 tabs = new JTabbedPane();
		 this.add(tabs);
		 tabs.addChangeListener(new TabChanged());
		 
		 booking_panel = BookingPanel.getInstance();
		 check_in_panel = new CheckInPanel();
		 check_out_panel = new CheckOutPanel();
		 view_guests_panel = new ViewGuestsPanel();
		 add_fees_panel = new AddFeesPanel();
		 admin_panel = new AdminPanel();
		 
		 tabs.addTab("Booking", booking_panel);
		 tabs.addTab("Check-In", check_in_panel);
		 tabs.addTab("Check-Out", check_out_panel);
		 tabs.addTab("Current Guests", view_guests_panel);
		 tabs.addTab("Add Fees", add_fees_panel);	
		 tabs.addTab("Admin", admin_panel);
		 
		 setVisible(true);
		 tabs.repaint();
	}
	
	private class TabChanged implements ChangeListener{

		@Override
		public void stateChanged(ChangeEvent e) {
			check_in_panel.UpdateTable();
			check_out_panel.UpdateTable();
			view_guests_panel.UpdateTable();
			
			tabs.repaint();
			
//			if(tabs.getSelectedComponent() == check_in_panel){
//				check_in_panel.Update();
//			}else if(tabs.getSelectedComponent() == check_out_panel){
//				check_out_panel.Update();
//			}else if(tabs.getSelectedComponent() == view_guests_panel){
//				view_guests_panel.Update();
//			}
			tabs.repaint();
		}
		
	}
}
